<template>
  <div class="subject">
    <span>{{item.num1}}</span>
    <span>+</span>
    <span>{{item.num2}}</span>
    <span>=</span>
    <input v-model="total" type="number" />
    <button @click="submit" >提交</button>
  </div>
</template>
n
<script>
export default {
  props: ['item'],
  data () {
    return {
      total: '' 
    }
  },
  methods: {
    submit() {
      if(this.total === '') return this.$emit('submit', 0)
      if (this.item.num1+this.item.num2 === Number(this.total)) {
        this.$emit('submit',1)
      } else (
        this.$emit('submit',2)
      )
    }
  }
};
</script>

<style scoped>
.subject {
  margin: 5px;
  padding: 5px;
  font-size: 20px;
}
.subject span {
  display: inline-block;
  text-align: center;
  width: 20px;
}
.subject input {
  width: 50px;
  height: 20px;
}
</style>